package leetcode.easy;

public class $09_Palindrome {
    public boolean isPalindrome(int x){
        if (x < 0)
            return false;
        if (x == 0)
            return true;
        String input = String.valueOf(x);
        for(int i = 0;i < input.length() / 2;i++){
            if (input.charAt(i) == input.charAt(input.length() - i - 1))
                continue;
            else
                return false;
        }
        return true;
    }

    public boolean isPalindrome1(int x){
        if (x < 0)
            return false;
        if (x == 0)
            return true;
        if (x % 10 == 0)
            return false;
        int revertedNumber = 0;
        while (x > revertedNumber) {
            revertedNumber = revertedNumber * 10 + x % 10;
            x /= 10;
        }
        return x == revertedNumber || x == revertedNumber / 10;
    }
}
